//package com.billow.book.config;
//
//import com.billow.book.component.MyRealm;
//import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
//import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
//import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * shiro类
// */
//@Configuration
//public class ShiroConfig {
//
//    @Autowired
//    private MyRealm myRealm;
//
//    //创建安全管理器
//    @Bean
//    public DefaultWebSecurityManager securityManager() {
//        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
//        //创建加密对象,指定加密策略
//        HashedCredentialsMatcher matcher = new HashedCredentialsMatcher();
//        matcher.setHashAlgorithmName("md5");
//        matcher.setHashIterations(6);
//        myRealm.setCredentialsMatcher(matcher);
//        securityManager.setRealm(myRealm);
//        return securityManager;
//    }
//
//    //配置Shiro过滤器
//    @Bean
//    public ShiroFilterFactoryBean shiroFilterFactoryBean(DefaultWebSecurityManager securityManager) {
//        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
//        //给ShiroFilter配置安全管理器
//        shiroFilterFactoryBean.setSecurityManager(securityManager);
//        Map<String, String> map = new HashMap<>();
//        //配置系统公共资源
//        //anon表示这个资源无需认证//配置系统受限资源
//        map.put("/user/login", "anon");
//        map.put("/login.html", "anon");
//        //authc表示这个资源需要认证和授权
//        map.put("/**", "authc");
//        shiroFilterFactoryBean.setLoginUrl("/login.html");
//        shiroFilterFactoryBean.setFilterChainDefinitionMap(map);
//        return shiroFilterFactoryBean;
//    }
//
//}